<?php 
namespace app\track\controller;
use app\track\service\TimeTrackService;
use think\Request;
use think\facade\Log;
/**
 * @title 时光轨迹
 * @description 时光轨迹
 */
class Index extends TimeTrackService
{
    /**
     * @title 时间列表
     * @description 时光轨迹时间列表
     * @module 轨迹模块
     * @author 凌杰
     * @url /track/index/time_list
     * @method POST
     * @param name:Openid type:string require:1 default:'' other: desc:用户的openid
     * @return code:错误码
     * @return msg:错误消息
     * @return data:错误消息@
     * @data year:年份
     */
    public function time_list(Request $request){
        if(!$request->isPost()) return False;
        $info=$request->param();
        $res = $this->time_lists($info);
        return json($res);
    }
    /**
     * @title 轨迹列表
     * @description 时光轨迹列表
     * @module 轨迹模块
     * @author 凌杰
     * @url /track/index/track_list
     * @method POST
     * @param name:Openid type:string require:1 default:'' other: desc:用户的openid
     * @param name:year type:int require:1 default:1 other: desc:年份 2018
     * @param name:month type:int require:1 default:1 other: desc:年份 12
     * @param name:page type:int require:0 default:1 other: desc:页数
     * @return code:错误码
     * @return msg:错误消息
     * @return id:tracktype为1相册id tracktype为2动态id tracktype为3任务完成id
     * @return id2:tracktype为1为图片id tracktype为2圈子id tracktype为3任务id
     * @return Time:轨迹时间
     * @return name:轨迹的标题
     * @return tracktype:轨迹类型 1为相册 2为蜗牛圈 3为蜗牛任务
     * @return data:错误消息@
     * @data image:图片路劲 
     */
    public function track_list(Request $request){
        if(!$request->isPost()) return False;
        $info=$request->param();
        $res = $this->track_lists($info);
        return json($res);
    }
	/**
     * @title 发布时光
     * @description 发布时光
     * @module 轨迹模块
     * @author 凌杰
     * @url /track/index/publish
     * @method POST
     * @param name:Openid type:string require:1 default:'' other: desc:为空表示登陆用户自己操作，否则表示当前的Openid用户操作
     * @param name:describe type:string require:1 default:'' other: desc:描述
     * @param name:imagefile type:图片文件数组 require:1 default:'' other: desc:图片文件数组
     * @param name:permissions type:int require:0 default:'' other: desc:权限1公开，2好友，3自己
     * @param name:trackregion type:string require:0 default:'' other: desc:地区
     * @return code:错误码
     * @return msg:错误消息
     */
    public function publish(Request $request)
    {
        if(!$request->isPost()) return False;
        $info=$request->param();
        $info['imagefile']=$request->file('imagefile');
        $res = $this->release_track($info);
        return json($res);
    }

    /**
     * @title 时光列表
     * @description 时光列表
     * @param name:Openid type:string require:1 default:'' other: desc:为空表示登陆用户自己操作，否则表示当前的Openid用户操作
     * @param name:page  type:int require:0  default:1  other: desc:页数
     * @param name:limit type:int require:0  default:10 other: desc:limit
     * @module 轨迹模块
     * @author 凌杰
     * @url /track/index/list
     * @method POST
     * @return code:错误码
     * @return msg:错误消息
     * @return image:错误消息@
     * @image Picspath:图片路劲
     */
    public function list(Request $request)
    {
        if(!$request->isPost()) return False;
        $info=$request->param();
        $info['Token'] = $this->user['Token'];
       
       // $info['imagefile']=$request->file('imagefile');
        $res = $this->track_list($info);
        return json($res);
    }
/**
     * @title 删除时光
     * @description 删除时光
     * @module 轨迹模块
     * @author 凌杰
     * @url /track/index/delete
     * @method POST
     * @param name:trackid type:id require:1 default:"" other: desc:时光轨迹id
     * @param name:is_delete type:bool require:0 default:'flase' other: desc:是否彻底删除，彻底删除不能找回，请谨慎
     * @return code:错误码
     * @return msg:错误消息
     */
    public function delete(Request $request)
    {
        if(!$request->isPost()) return False;
        $info=$request->param();
        $res = $this->del_track($info);
        return json($res);
    }

    /**
     * @title 时光评论
     * @description 评论列表
     * @param name:trackid  type:int require:1  default:1  other: desc:时光id
     * @param name:page  type:int require:0  default:1  other: desc:页数
     * @param name:limit type:int require:0  default:10 other: desc:limit
     * @module 轨迹模块
     * @author 凌杰
     * @url /track/index/comment
     * @method POST
     * @return code:错误码
     * @return msg:错误消息
     * @return image:错误消息@
     * @image Picspath:图片路径
     */
    public function comment(Request $request)
    {
        if(!$request->isPost()) return False;
        $info=$request->param();
       // $info['imagefile']=$request->file('imagefile');
        $res = $this->comment_list($info);
    
        return json($res);
    }


      /**
    * @title 增加评论
    * @description 增加评论
    * @module 轨迹模块
    * @author 凌杰
    * @url /track/index/add_comment
    * @method POST
    * @param name:trackid type:id require:0 default:"" other: desc:轨迹id
    * @param name:content type:string require:1 default:'' other: desc:评论内容
    * @param name:Replayid type:string require:1 default:'' other: desc:被评论人id    
    * @return code:错误码
    * @return msg:错误消息
    */
    public function add_comment(Request $request){
        $info=$request->param();
        $res = $this->comments($info);
        return json($res);
    }


      /**
    * @title 点赞
    * @description 点赞和取消点赞
    * @module 轨迹模块
    * @author 凌杰
    * @url /track/index/point
    * @method POST
    * @param name:trackid type:id require:0 default:"" other: desc:轨迹id
    * @return code:错误码
    * @return msg:错误消息
    */
    public function point(Request $request){
        $info=$request->param();
        $res = $this->add_points($info);
        return json($res);
    }
    public function test(Request $request){
   /* dump($request->param());
	echo '<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="/talbum/index/photo_upload" enctype="multipart/form-data" method="post">
<input type="text" name="albumid" value=10> <br>
    <input type="file" name="imagefile[]" /> <br>
    <input type="file" name="imagefile[]" /> <br>
    <input type="file" name="imagefile[]" /> <br>
    <input type="text" name="picsname[]" value="picsname"/> <br>
    <input type="text" name="picsname[]" value="picsname"/> <br>
    <input type="text" name="picsname[]" value="picsname"/> <br>
    <input type="text" name="Iscover[]" value=0 /> <br>
    <input type="text" name="Iscover[]" value=0 /> <br>
    <input type="text" name="Iscover[]" value=1/> <br>


    <input type="submit" value="上传" />
</form>

</body>
</html>';*/
    echo '<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="/track/index/publish" enctype="multipart/form-data" method="post">
<input type="text" name="describe" value="name"> <br>
<input type="text" name="permissions" value="123"/> <br>
<input type="text" name="trackregion" value="videoregion"/> <br>
   
    <input type="file" name="imagefile[]" /> <br>
      <input type="file" name="imagefile[]" /> <br>

    <input type="submit" value="上传" />
</form>

</body>
</html>';

}
}